package com.ssy.lingxi.common.constant.settle;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 平台规则配置 - 结算支付方式
 * @author 万宁
 * @version 2.0.0
 * @date 2021-12-03
 */
public enum SettlementTypeEnum {
    /**
     * 线下结算 - 1
     */
    OFFLINE(1, "线下结算"),

    /**
     * 通联支付结算 - 2
     */
    ALLIN_PAY(2, "通联支付结算");

    SettlementTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;
    private String name;

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getName(Integer code) {
        return Arrays.stream(SettlementTypeEnum.values()).filter( e -> e.getCode().equals(code)).findFirst().orElse(OFFLINE).getName();
    }
}
